class AccountsController < ApplicationController
  
  def new
    @account = Account.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @account }
    end
  end
  
  def create
    @account = Account.new(params[:account])
    @account.user = current_user
    respond_to do |format|
      if @account.save
        flash[:notice] = 'Account was successfully created.'
        format.html { redirect_to(burndowns_path) }
        format.xml  { render :xml => @account, :status => :created, :location => @account }
      else
        format.html do 
          render :action => "new"
        end
        format.xml  { render :xml => @account.errors, :status => :unprocessable_entity }
      end
    end
  end
  
  def edit
    @account = Account.find(params[:id])
  end
  
  def update
    @account = Account.find(params[:id])

    respond_to do |format|
      if @account.update_attributes(params[:account])
        flash[:notice] = 'Account was successfully updated.'
        format.html { redirect_to(burndowns_path) }
        format.xml  { head :ok }
      else
        format.html do 
          render :action => "edit" 
        end
        format.xml  { render :xml => @account.errors, :status => :unprocessable_entity }
      end
    end
  end
  
end
